home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / T / The Survey Editor2.0.HC.cpt / The Survey Editor 2.0 / background_2767.txt < prev    next >
Text File  |  1990-01-30  |  9KB  |  313 lines

  1. -- background: 2767 from stack: in.0
  2. -- bmap block id: 3303
  3. -- flags: 4000
  4. -- background id: 0
  5. -- name: 
  6. ----- HyperTalk script -----
  7. on domenu which
  8.   if which is in "about...,New,open...,Save,save as...,revert,print...," & "print code...,show all code,Show code of a line...,Home,add," & "insert,Edit,replace,delete,label above command" then
  9.     lock screen
  10.     if which is "About..." then
  11.       set cursor to watch
  12.       go cd "about"
  13.       unlock screen with iris open
  14.       hide menubar
  15.       exit domenu
  16.     end if
  17.     if which is "open..." then
  18.       go cd 1
  19.       if check_empty() is true then exit domenu
  20.       open_a_file
  21.       exit domenu
  22.     end if
  23.     if which is "new" then
  24.       set lockMessages to true
  25.       go cd 1
  26.       if check_empty() is true then exit domenu
  27.       put empty into cd field "survey"
  28.       set the scroll of cd field "survey" to 0
  29.       put "Untitled" into line 1 of cd field "file"
  30.       set the width of cd field "file" to 74
  31.       set the visible of cd btn "commands" to true
  32.       go cd "survey file"
  33.       put "" into cd field "survey file"
  34.       set the scroll of cd field "survey file" to 0
  35.       go cd 1
  36.       clearHiliteBtn
  37.       exit domenu
  38.     end if
  39.     if which is "save" then
  40.       set lockMessages to true
  41.       if line 1 of cd field "file" = "Untitled" then
  42.         get save_survey()
  43.       else
  44.         go cd 1
  45.         put line 2 of cd field "file" into fichier
  46.         go cd "survey file"
  47.         WriteToFile cd field "survey file",true,fichier,false,"MACA"
  48.         go cd 1
  49.       end if
  50.       exit domenu
  51.     end if
  52.     if which is "save as..." then
  53.       get save_survey()
  54.       exit domenu
  55.     end if
  56.     if which is "revert" then
  57.       answer "Revert to the last saved version?" with "Yes" or "Cancel"
  58.       if it is "cancel" then exit domenu
  59.       go cd 1
  60.       open_a_file (line 2 of cd field "file")
  61.       exit domenu
  62.     end if
  63.     if which is "print..." then
  64.       go cd 1
  65.       printField "cd field id 1",2,0,0,0,0
  66.       exit domenu
  67.     end if
  68.     if which is "print code..." then
  69.       go cd "survey file"
  70.       printField "cd field id 3",2,36,36,36,36
  71.       go cd 1
  72.       exit domenu
  73.     end if
  74.     if which is "show all code" then
  75.       go cd "survey file"
  76.       set the scroll of cd field "survey file" to 0
  77.       exit domenu
  78.     end if
  79.     if which is "label above command" then
  80.       unlock screen
  81.       set the hilite of btn which to not the hilite of btn which
  82.       label_above
  83.       set the scroll of cd field "survey" to 0
  84.       exit domenu
  85.     end if
  86.     if which is "home" then
  87.       go home
  88.       exit domenu
  89.     end if
  90.  
  91.     if cd field id 99 is empty and which ‚↠"add" then
  92.       answer "You must select a line first."
  93.       exit domenu
  94.     end if
  95.  
  96.     if which is "show code of a line..." then
  97.       put "Please, click on a line to show it's code or click here to cancel." into cd field "header"
  98.       unlock screen
  99.       Edit_a_line false
  100.       exit domenu
  101.     end if
  102.  
  103.     put which into line 1 of cd field "action"
  104.     put which into line 3 of cd field "action"
  105.     if which is "Edit" then
  106.       put "Please, click on the line to Edit or click here to cancel." into cd field "header"
  107.       unlock screen
  108.       Edit_a_line true
  109.       exit domenu
  110.     end if
  111.  
  112.     if which is "delete" then
  113.       delete_a_line
  114.       exit domenu
  115.     end if
  116.  
  117.     show cd field "Header"
  118.  
  119.     put "Action selected was ‚Äú" & which & "‚Äù. Click on a line or click here to cancel." into cd field "header"
  120.     show cd field "commandLIST"
  121.     show cd field "command # list"
  122.     show cd field "command number"
  123.     show cd field "label command number"
  124.     unlock screen
  125.     put "" into cd field "command number"
  126.     click at the loc of cd field "command number"
  127.   else
  128.     pass domenu
  129.   end if
  130. end domenu
  131.  
  132. on open_a_file fichier
  133.   set lockMessages to true
  134.   if fichier = "" then
  135.     put fileName("TEXT","Select your Survey file...") into fichier
  136.     if fichier is empty then exit open_a_file
  137.     go cd 1
  138.     put fichier into line 2 of cd field "file"
  139.   end if
  140.   clearHiliteBtn
  141.   show cd field "wait"
  142.   unlock screen
  143.   lock screen
  144.   set the hilite of cd btn "Label above command" to false
  145.   menuHandler "mark","commands","Label Above Command","none"
  146.   put empty into cd field "survey"
  147.   unlock screen
  148.   lock screen
  149.   go cd "survey file"
  150.   put empty into cd field "survey file"
  151.   open file fichier
  152.   read from file fichier for 32768
  153.   put it into cd field "survey file"
  154.   set the scroll of cd field "survey file" to 0
  155.   close file fichier
  156.   put verbose() into computed
  157.   go cd 1
  158.   put computed into cd field "survey"
  159.   set the scroll of cd field "survey" to 0
  160.   hide cd field "wait"
  161.   put realName(fichier) into line 1 of cd field "file"
  162.   set the visible of cd btn "commands" to true
  163.   set the width of cd field "file" to (stringWidth(line 1 of cd field "file","Chicago",12))+20
  164.   repeat with x = 2 to 5
  165.     menuHandler "enable","commands",x
  166.   end repeat
  167.   menuHandler "enable","Editor",13
  168. end open_a_file
  169.  
  170. on delete_a_line
  171.   set cursor to watch
  172.   set lockMessages to true
  173.   put item 2 of cd field id 99 into theLine
  174.   if the shiftKey is up then
  175.     put line theLine of cd field "survey" into cd field "command selected"
  176.     show cd btn "delete this command?"
  177.     show cd field "command selected"
  178.     show cd btn "yes"
  179.     show cd btn "cancel"
  180.     unlock screen
  181.     set cursor to hand
  182.     wait until the mouseClick
  183.     put the clickLoc into clickLic
  184.     if clickLic is not within the rect of cd btn "yes" then
  185.       set the hilite of cd btn "cancel" to true
  186.       wait 5 ticks
  187.       set the hilite of cd btn "cancel" to false
  188.       send mouseUp to cd btn "cancel"
  189.       exit delete_a_line
  190.     end if
  191.     set the hilite of cd btn "yes" to true
  192.     wait 5 ticks
  193.     set the hilite of cd btn "yes" to false
  194.     send mouseUp to cd btn "yes"
  195.     lock screen
  196.   end if
  197.   set the hilite of cd btn id (item 1 of cd field id 99) to false
  198.   put "" into cd field id 99
  199.   set cursor to watch
  200.   delete line theLine of cd field "survey"
  201.   go cd "survey file"
  202.   delete line (((theLine-1) * 6) +1) to (theLine * 6) of cd field "survey file"
  203.   go cd 1
  204. end delete_a_line
  205.  
  206. function save_survey
  207. go cd 1
  208. put NewfileName("Save as...",line 1 of cd field "file") into fichier
  209. if fichier is empty then
  210.   return false
  211.   exit save_survey
  212. end if
  213. go cd "survey file"
  214. WriteToFile cd field "survey file",true,fichier,false,"MACA"
  215. go cd 1
  216. put realName(fichier) into line 1 of cd field "file"
  217. set the width of cd field "file" to (stringWidth(line 1 of cd field "file","Chicago",12))+20
  218. return true
  219. end save_survey
  220.  
  221. on label_above
  222.   clearHiliteBtn
  223.   show cd field "wait2"
  224.   lock screen
  225.   set cursor to watch
  226.   put the hilite of cd btn "label above command" into state
  227.   if state is true then
  228.     repeat with x = 2 to 5
  229.       menuHandler "disable","commands",x
  230.     end repeat
  231.     menuHandler "disable","Editor",13
  232.     menuHandler "mark","commands","Label Above Command","check"
  233.   else
  234.     repeat with x = 2 to 5
  235.       menuHandler "enable","commands",x
  236.     end repeat
  237.     menuHandler "enable","Editor",13
  238.     menuHandler "mark","commands","Label Above Command","none"
  239.   end if
  240.   togglePosition state
  241.   hide cd field "wait2"
  242. end label_above
  243.  
  244. function check_empty
  245. put false into checked
  246. set lockMessages to true
  247. go cd "survey file"
  248. if cd field "survey file" ‚↠"" then
  249.   answer "Do you want to save this survey?" with "Yes" or "No" or "Cancel"
  250.   if it is "Yes" then
  251.     if save_survey() is false then
  252.       put true into checked
  253.     end if
  254.   else
  255.     if it is "Cancel" then put true into checked
  256.   end if
  257. end if
  258. go cd 1
  259. return checked
  260. end check_empty
  261.  
  262. on Edit_a_line Edit
  263.   set cursor to watch
  264.   lock screen
  265.   put (item 2 of cd field id 99) into theline
  266.   put "replace" into line 1 of cd field "action"
  267.   put theLine into line 2 of cd field "action"
  268.   put line theline of cd field "survey" into isCR
  269.   go cd "survey file"
  270.   put (((theLine-1) * 6) +1)  into firstLine
  271.   put line firstLine of cd field "survey file" into comment
  272.   put line firstLine+1 of cd field "survey file" into name
  273.   put line firstLine+2 of cd field "survey file" into tType
  274.   put line firstLine+3 of cd field "survey file" into text
  275.   put line firstLine+4 of cd field "survey file" into length
  276.   put line firstLine+5 of cd field "survey file" into branch
  277.   go cd 1
  278.   put line tType+1 of cd field "commandLIST" into displayString
  279.   put "0,5,6,8,18,37,38,43,44,45,46" into exceptions
  280.   repeat with x = 1 to 11
  281.     if tType = item x of exceptions then
  282.       answer "Not available for this command."
  283.       exit Edit_a_line
  284.     end if
  285.   end repeat
  286.   command tType,displayString
  287.   put comment into cd field "comment"
  288.   put length into cd field "length"
  289.   put name into cd field "name"
  290.   put branch into cd field "branch"
  291.   put text into cd field "input"
  292.   if "with a cr" is in isCR
  293.   then set the hilite of cd btn id 2 to true -- terminate with a return
  294. else set the hilite of cd btn id 2 to false
  295. if Edit is false then
  296.   unlock screen
  297.   hide cd btn "cancel"
  298.   hide cd btn "ok"
  299.   unlock Screen
  300.   wait until the mouseClick
  301.   lock screen
  302.   go cd 1
  303.   unlock screen with barn door open
  304. end if
  305. end Edit_a_line
  306.  
  307. on clearHiliteBtn
  308.   if cd field id 99 ‚↠""
  309.   then set the hilite of cd btn id (item 1 of cd field id 99) to false
  310.   put "" into cd field id 99
  311. end ClearHiliteBtn
  312.  
  313.